package top.kaoshanji.p1ch03b;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import top.kaoshanji.u1constant.FileConstant;

import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * 代码清单 p1ch03b-06：目录列表流的使用示例
 * author kaoshanji
 * ^_^
 * create time 2025/1/10 20:27
 */
public class DirectoryStreamExample01 {

    private static final Logger logger = LogManager.getLogger(DirectoryStreamExample01.class);

    public static void main(String[] args) {
        logger.info("...代码清单 p1ch03b-06：目录列表流的使用示例...");

        Path path = Paths.get(FileConstant.LOCAL_ROOT_PATH.concat("java7-pro-cheng"));
        try (DirectoryStream<Path> stream = Files.newDirectoryStream(path, "*.*")){
            for (Path entry: stream) {
                System.out.println(entry);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }

}
